﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_FileList.cs
文件名称：FileList.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/17
作　　者：
内容摘要：表[File_List]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：FileList
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class FileList : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is FileList)
				{
					if (obj == this)
						return true;
					FileList castObj = (FileList)obj; 
					
					if (!this.m_Seqno.Equals(castObj.Seqno))
						return false;
						
					if (!this.m_KeyValue.Equals(castObj.KeyValue))
						return false;
						
					if (!this.m_KeyType.Equals(castObj.KeyType))
						return false;
						
					if (!this.m_FilePath.Equals(castObj.FilePath))
						return false;
						
					if (!this.m_FileName.Equals(castObj.FileName))
						return false;
						
					if (!this.m_Sequence.Equals(castObj.Sequence))
						return false;
						
					if (!this.m_Islink.Equals(castObj.Islink))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Seqno != null)
					{
						hash = hash ^ m_Seqno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_KeyValue != null)
					{
						hash = hash ^ m_KeyValue.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_KeyType != null)
					{
						hash = hash ^ m_KeyType.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_FilePath != null)
					{
						hash = hash ^ m_FilePath.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_FileName != null)
					{
						hash = hash ^ m_FileName.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Sequence != null)
					{
						hash = hash ^ m_Sequence.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Islink != null)
					{
						hash = hash ^ m_Islink.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public FileList()
			{
				MarkNew();
			}						
			
			public FileList GetOldValue()
			{
				return OldValue as FileList;
			}
		
		#region Seqno属性
			private int m_Seqno = 0;
			/// <summary>
			/// 属性名称： Seqno
			/// 内容摘要： DB列名：Seqno[]
			///            DB类型：int
			/// </summary>
			public int Seqno
			{
				get
					{
						return m_Seqno;
					}
				set
					{
						if (m_Seqno as object == null || !m_Seqno.Equals(value))
						{
							m_Seqno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region KeyValue属性
			private int m_KeyValue = 0;
			/// <summary>
			/// 属性名称： KeyValue
			/// 内容摘要： DB列名：key_value[]
			///            DB类型：int
			/// </summary>
			public int KeyValue
			{
				get
					{
						return m_KeyValue;
					}
				set
					{
						if (m_KeyValue as object == null || !m_KeyValue.Equals(value))
						{
							m_KeyValue = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region KeyType属性
			private string m_KeyType = String.Empty;
			/// <summary>
			/// 属性名称： KeyType
			/// 内容摘要： DB列名：key_Type[]
			///            DB类型：string
			/// </summary>
			public string KeyType
			{
				get
					{
						return m_KeyType;
					}
				set
					{
						if (m_KeyType as object == null || !m_KeyType.Equals(value))
						{
							m_KeyType = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region FilePath属性
			private string m_FilePath = String.Empty;
			/// <summary>
			/// 属性名称： FilePath
			/// 内容摘要： DB列名：File_Path[]
			///            DB类型：string
			/// </summary>
			public string FilePath
			{
				get
					{
						return m_FilePath;
					}
				set
					{
						if (m_FilePath as object == null || !m_FilePath.Equals(value))
						{
							m_FilePath = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region FileName属性
			private string m_FileName = String.Empty;
			/// <summary>
			/// 属性名称： FileName
			/// 内容摘要： DB列名：File_Name[]
			///            DB类型：string
			/// </summary>
			public string FileName
			{
				get
					{
						return m_FileName;
					}
				set
					{
						if (m_FileName as object == null || !m_FileName.Equals(value))
						{
							m_FileName = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Sequence属性
			private int m_Sequence = 0;
			/// <summary>
			/// 属性名称： Sequence
			/// 内容摘要： DB列名：Sequence[]
			///            DB类型：int
			/// </summary>
			public int Sequence
			{
				get
					{
						return m_Sequence;
					}
				set
					{
						if (m_Sequence as object == null || !m_Sequence.Equals(value))
						{
							m_Sequence = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Islink属性
			private int m_Islink = 0;
			/// <summary>
			/// 属性名称： Islink
			/// 内容摘要： DB列名：IsLink[]
			///            DB类型：int
			/// </summary>
			public int Islink
			{
				get
					{
						return m_Islink;
					}
				set
					{
						if (m_Islink as object == null || !m_Islink.Equals(value))
						{
							m_Islink = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("key_value",typeof(int)));
					dtResult.Columns.Add(new DataColumn("key_Type",typeof(string)));
					dtResult.Columns.Add(new DataColumn("File_Path",typeof(string)));
					dtResult.Columns.Add(new DataColumn("File_Name",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Sequence",typeof(int)));
					dtResult.Columns.Add(new DataColumn("IsLink",typeof(int)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("KeyValue",typeof(int)));
					dtResult.Columns.Add(new DataColumn("KeyType",typeof(string)));
					dtResult.Columns.Add(new DataColumn("FilePath",typeof(string)));
					dtResult.Columns.Add(new DataColumn("FileName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Sequence",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Islink",typeof(int)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["key_value"] = this.KeyValue;
					dr["key_Type"] = this.KeyType;
					dr["File_Path"] = this.FilePath;
					dr["File_Name"] = this.FileName;
					dr["Sequence"] = this.Sequence;
					dr["IsLink"] = this.Islink;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["KeyValue"] = this.KeyValue;
					dr["KeyType"] = this.KeyType;
					dr["FilePath"] = this.FilePath;
					dr["FileName"] = this.FileName;
					dr["Sequence"] = this.Sequence;
					dr["Islink"] = this.Islink;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成FileList对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>FileList对象</returns>
			public static FileList Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				FileList obj = new FileList();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.KeyValue = (dr["key_value"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["key_value"],typeof(int));
					obj.KeyType = (dr["key_Type"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["key_Type"],typeof(string));
					obj.FilePath = (dr["File_Path"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["File_Path"],typeof(string));
					obj.FileName = (dr["File_Name"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["File_Name"],typeof(string));
					obj.Sequence = (dr["Sequence"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Sequence"],typeof(int));
					obj.Islink = (dr["IsLink"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["IsLink"],typeof(int));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.KeyValue = (dr["KeyValue"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["KeyValue"],typeof(int));
					obj.KeyType = (dr["KeyType"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["KeyType"],typeof(string));
					obj.FilePath = (dr["FilePath"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["FilePath"],typeof(string));
					obj.FileName = (dr["FileName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["FileName"],typeof(string));
					obj.Sequence = (dr["Sequence"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Sequence"],typeof(int));
					obj.Islink = (dr["Islink"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Islink"],typeof(int));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成FileList对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>FileList对象</returns>
			public static FileList Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的FileList对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>FileList对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的FileList对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>FileList对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的FileList对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">FileList对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(FileList obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的FileList对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">FileList对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			FileList old = this.OldValue as FileList;
			if (old != null)
			{
					this.Seqno = old.Seqno;
					this.KeyValue = old.KeyValue;
					this.KeyType = old.KeyType;
					this.FilePath = old.FilePath;
					this.FileName = old.FileName;
					this.Sequence = old.Sequence;
					this.Islink = old.Islink;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region FileList实体的内部Key类
			/// <summary>
			/// FileList实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Seqno;
				public int Seqno
				{
 					get 
					{ 
						 return m_Seqno; 
					}
					set 
					{ 
						m_Seqno = value;
					}
				}
		
				public Key(int pSeqno)
				{
					m_Seqno=pSeqno;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体FileList的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Seqno);				
			}
			
				
		#endregion
	}
}
